#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int missingNumber(vector<int>& nums)
    {
        int n = nums.size();

        int sumToN = 0;
        for (int i = 1; i <= n; ++i)
        {
            sumToN += i;
        }

        int sum = 0;
        for (int i = 0; i < n; ++i)
        {
            sum += nums[i];
        }

        return sumToN - sum;
    }
};